package com.markus.code.exam.qianxin;

/**
 * Author:markusZhang
 * Date:Create in 2020/9/12 10:58
 * todo:
 */
public class Main1 {
    /**
     * 获得剩余区域内的最大干净矩形面积
     *
     * @param x1 int整型
     * @param y1 int整型
     * @param x2 int整型
     * @param y2 int整型
     * @param x3 int整型
     * @param y3 int整型
     * @param x4 int整型
     * @param y4 int整型
     * @return int整型
     */
    public int getMaxArea(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4) {
        // write code here
        boolean first = (x1 >= x3 && x1 <= x4) || (x2 >= x3 && x2 <= x4);
        boolean last = (y1 >= y3 && y1 <= y4) || (y2 >= y3 && y2 <= y4);
        int ans = 0;
        int d = Math.min(y1, y3) * 10;
        int r = Math.max(x2, x4) * 10;
        int u = Math.max(y2, y4) * 10;
        int l = Math.min(x1, x3) * 10;
        ans = Math.max(ans, d);
        ans = Math.max(ans, r);
        ans = Math.max(ans, u);
        ans = Math.max(ans, l);
        if (first && last) {
            int zs = Math.min(y2, y4) * Math.max(x1, x3);
            ans = Math.max(ans, zs);
            int ys = Math.min(y2, y4) * (10 - Math.min(x2, x4));
            ans = Math.max(ans, ys);
            int zx = Math.max(y1, y3) * Math.max(x1, x3);
            ans = Math.max(ans, zx);
            int yx = Math.min(x2, x4) * Math.max(y1, y3);
            ans = Math.max(ans, yx);
        }
        return ans;
    }
}
